<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* body {
            position: relative;
        } */

        /* .ul {
            width: 205px;
            height: 200px;
            position: fixed;
            top: 87px;
            right: 100px;
            background-color: aquamarine;

        } */
        .sat {
            position: fixed;
            right: 20px;
            top: 300px;
            list-style: none;
            width: 80px;
            height: 100px;
            background-color: rgba(207, 32, 41, 0.247);
            color: #3a3a3a83;
            ;
            box-shadow: 3px 3px 2px rgba(226, 214, 214, 0.247);
            z-index: 2;
        }
    </style>
</head>

<body>
    <input type="text" id="input">
    <div class="sat">
        <ul id="ul"></ul>
    </div>


    </ul>
    <script>
        var arr = [
            { id: 1001, name: "计算器", price: 26 },
            { id: 1002, name: "计算机", price: 26 },
            { id: 1003, name: "飞机", price: 26 },
            { id: 1004, name: "飞行器", price: 26 },
            { id: 1005, name: "算盘", price: 26 },
            { id: 1006, name: "电器", price: 26 },
            { id: 1007, name: "电视机", price: 26 },
        ]
        var input = document.getElementById("input");
        var ul = document.getElementById("ul");

        input.oninput = function () {
            ul.innerHTML = arr.reduce(function (value, item) {
                if (item.name.indexOf(input.value) > -1) value += "<li>" + item.name + "</li>";
                return value;
            }, "");
        }

        // oninput输入时显示内容，调用reduce函数，判断在输入内容中与元素是否相同，将元素返回给ul列表内





















    </script>
</body>

</html>